package org.dzq.designmode.prototype;

import lombok.Data;
import org.dzq.designmode.prototype.bean.Student;

/**
 * @ClassName: PrototypeMode
 * @Package: org.dzq.designmode.prototype
 * @author: 越
 * @date: 2023/6/12 21:48
 * @Description: 浅拷贝原型模式
 */
@Data
public class ShallowClonePrototype implements Cloneable{

    private String name;

    private int age;

    private Student student;

    /**
     * super.clone()是来自Object的clone方法,它只拷贝student的引用,而没有实际生成一块新的内存
     * @return
     * @throws CloneNotSupportedException
     */
    @Override
    protected ShallowClonePrototype clone() throws CloneNotSupportedException {
        return (ShallowClonePrototype)super.clone();
    }
}
